package com.heima.article.feign;

import com.heima.article.service.ApArticleService;
import com.heima.client.article.IArticleClient;
import com.heima.model.common.dtos.ArticleDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class ArticleClient implements IArticleClient {

    @Autowired
    private ApArticleService apArticleService;
    /**
     * 保存或修改article文章信息
     * @param articleDto
     * @return
     */
    @PostMapping("/api/v1/article/sync")
    public ResponseResult syncArticle(@RequestBody ArticleDto articleDto) {
        log.info("article文章同步开始：{}",articleDto);
        /* try {
            Thread.sleep(10000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
        return apArticleService.saveOrUpdateArticle(articleDto);
    }
}
